package com.ls.controller;

import com.ls.entity.Result;
import com.ls.pojo.User;
import com.ls.pojo.UserScore;
import com.ls.service.IUserScoreService;
import com.ls.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaotang
 * @since 2023-04-07
 */
@RestController
@RequestMapping("/userScore")
public class UserScoreController {

    @Autowired
    private IUserScoreService userScoreService;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;


    @GetMapping("/{userId}/{addscore}/{action}")
    public Result<UserScore> addBuyscore(@PathVariable Integer userId,@PathVariable Integer addscore,@PathVariable Integer action) {

        Boolean flag = userScoreService.addBuyscore(userId,addscore,action);
        if (!flag){
            return new Result(500, "添加用户积分失败", flag);
        }
        return new Result(200, "添加用户积分成功", flag);
    }





}
